﻿<Page 
    x:Class="Microsoft.Samples.Office.UnifiedCommunications.Gadget.DesktopContacts"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Microsoft.Samples.Office.UnifiedCommunications.Gadget"
    Title="Desktop Contacts"
    ShowsNavigationUI="False" 
    ClipToBounds="True">     
    <Page.Resources>
        <Storyboard x:Key="LoadAni">
            <local:BackDoubleAnimation Completed="BackDoubleAnimation_Completed" From="300" To="0" Duration="0:0:0.8" EdgeBehavior="EaseOut" Amplitude=".5"   Suppression="0" DecelerationRatio=".5" Storyboard.TargetName="mainGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)"/>
        </Storyboard>

        <Style x:Key="textBoxStyleContact" BasedOn="{x:Null}" TargetType="{x:Type TextBox}">
            <EventSetter Event="GotFocus" Handler="TextBox_GotFocus"/>
            <EventSetter Event="LostFocus" Handler="TextBox_LostFocus"/>
            <EventSetter Event="GotMouseCapture" Handler="TextBox_GotFocus"/>

            <Setter Property="SnapsToDevicePixels" Value="True"/>
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="MinWidth" Value="150"/>
            <Setter Property="Height" Value="Auto" />
            <Setter Property="AllowDrop" Value="true"/>
            <Setter Property="Foreground" Value="#FF3D4F73" />
            <Setter Property="FontFamily" Value="Calibri" />
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TextBox}">
                        <Border 
                        x:Name="Border"
                        CornerRadius="2" 
                        Padding="2"            
                        BorderBrush="#FF3D4F73"
                        BorderThickness="1" >
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                    <GradientStop Color="#FFFFFFFF" Offset="0.272"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <ScrollViewer Margin="0" x:Name="PART_ContentHost"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False" />
                            <Trigger Property="IsFocused" Value="True">
                                <Setter Property="Background" TargetName="Border">
                                    <Setter.Value>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFDCDCDC" Offset="0"/>
                                            <GradientStop Color="#FFFFFFFF" Offset="0.272"/>
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                                <Setter Property="BorderThickness" TargetName="Border" Value="1.3,1.3,1.3,1.3"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Page.Resources>
    
    <Page.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource LoadAni}"/>
        </EventTrigger>
    </Page.Triggers>
    
    <Grid x:Name="mainGrid">
        <Grid.RenderTransform>
            <TranslateTransform X="0" Y="0"/>
        </Grid.RenderTransform>
        <Border BorderThickness="1,1,1,1" BorderBrush="#FF333945" CornerRadius="9,9,9,9">
            <Border Width="Auto" Height="Auto" BorderBrush="#FF161D25" BorderThickness="1,1,1,1" CornerRadius="8,8,8,8">
                <Grid Width="Auto" Height="Auto" x:Name="ContentGrid">
                    <Rectangle Stroke="{x:Null}" RadiusX="8" RadiusY="8" Width="Auto" Height="Auto" MinHeight="380" MinWidth="280">
                        <Rectangle.Fill>
                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#FFDAE3EF" Offset="0"/>
                                <GradientStop Color="#FFE2EBF1" Offset="1"/>
                            </LinearGradientBrush>
                        </Rectangle.Fill>
                    </Rectangle>
                    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" Text="Desktop Contact Configuration" TextWrapping="Wrap" Foreground="#FF3D4F73" FontFamily="Calibri" FontSize="16" FontWeight="Bold" Margin="0,10,0,0"/>
                    
                    <Grid x:Name="gridContent" Margin="5,40,5,35" HorizontalAlignment="Center">
                        <Grid.Resources>                        
                            <local:IsEmptyDesktopContactSipUri x:Key="isEmptyDesktopContactSipUriConverter" />
                            <local:IsEmptyDesktopContactDisplayName x:Key="isEmptyDesktopContactDisplayNameConverter" />
                                
                            <DataTemplate x:Key="contactEntryTemplate">
                                <Grid Margin="0 0 0 10" ClipToBounds="False">
                                    <Grid.RowDefinitions>
                                        <RowDefinition />
                                        <RowDefinition />
                                    </Grid.RowDefinitions>

                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="35"/>
                                        <ColumnDefinition Width="150"/>
                                        <ColumnDefinition Width="30"/>
                                    </Grid.ColumnDefinitions>
                                    
                                    <CheckBox x:Name="chkVisible" Grid.Column="0" Grid.RowSpan="2" 
                                              HorizontalAlignment="Left" VerticalAlignment="Center"
                                              Margin="0,0,0,0"
                                              Style="{DynamicResource BigCheckBoxStyle}" 
                                              IsChecked="{Binding Path=Visible}"
                                              Tag="{Binding Path=ContactId}"
                                              Checked="chkVisible_Checked"
                                              Unchecked="chkVisible_Unchecked"/>
                                    
                                    <Border x:Name="borderContactSipUri" BorderBrush="#999999" Width="150" 
                                            BorderThickness="1" Padding="0" CornerRadius="2" Grid.Column="1" 
                                            Grid.Row="0" Margin="0,0,0,5" VerticalAlignment="Center">
                                        <Label x:Name="lblContactSipUri"  
                                               MinWidth="150" Width="150" Height="Auto"
                                               Padding="2"
                                               Margin="0,0,0,0"
                                               FontFamily="Calibri" 
                                               Foreground="#FF3D4F73" Background="#6FFFFFFF" 
                                               Content="{Binding Path=SipUri, Mode=TwoWay}" 
                                               AllowDrop="True" Drop="Object_Drop"
                                               Style="{Binding Path=SipUri, 
                                                Converter={StaticResource isEmptyDesktopContactSipUriConverter}}"/>
                                    </Border>

                                    <Border x:Name="borderDisplayName" BorderBrush="#999999" Width="150" 
                                            BorderThickness="1" Padding="0" CornerRadius="2" Grid.Column="1" 
                                            Grid.Row="1" Margin="0,0,0,0" VerticalAlignment="Center">
                                        <Label x:Name="lblContactDisplayName" 
                                               MinWidth="150" Width="150" Height="Auto" 
                                               Padding="2"
                                               Margin="0,0,0,0"
                                               FontFamily="Calibri"
                                               Foreground="#FF3D4F73" Background="#6FFFFFFF" 
                                               Content="{Binding Path=DisplayName, Mode=TwoWay}" 
                                               Style="{Binding Path=DisplayName, 
                                                Converter={StaticResource isEmptyDesktopContactDisplayNameConverter}}"/>
                                    </Border>
                                    
                                    <TextBox x:Name="txtContactSipUri" Width="150" 
                                             Style="{DynamicResource textBoxStyleContact}"
                                             Text="{Binding Path=SipUri, Mode=TwoWay}" Visibility="Collapsed" 
                                             Grid.Column="1" Grid.Row="0" Margin="0,0,0,5"
                                             IsEnabled="False"/>
                                    
                                    <TextBox x:Name="txtContactDisplayName" Width="150" 
                                             Style="{DynamicResource textBoxStyleContact}"
                                             Text="{Binding Path=DisplayName, Mode=TwoWay}" Visibility="Collapsed" 
                                             Grid.Column="1" Grid.Row="1"/>
                                    
                                    <StackPanel Margin="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" 
                                                Grid.Column="2" Grid.RowSpan="2" >
                                        <Image x:Name="imgDelete" Tag="{Binding Path=ContactId}" Width="14" Height="14" 
                                               MouseDown="imgDelete_MouseDown" Source="{DynamicResource iconDelete}" 
                                               VerticalAlignment="Center" Margin="0,0,0,0"/>
                                    </StackPanel>
                                </Grid>
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}" Value="true">
                                        <Setter TargetName="txtContactSipUri" Property="Visibility" Value="Visible" />
                                        <Setter TargetName="lblContactSipUri" Property="Visibility" Value="Collapsed" />
                                        <Setter TargetName="borderContactSipUri" Property="Visibility" Value="Collapsed" />
                                        <Setter TargetName="txtContactDisplayName" Property="Visibility" Value="Visible" />
                                        <Setter TargetName="lblContactDisplayName" Property="Visibility" Value="Collapsed" />
                                        <Setter TargetName="borderDisplayName" Property="Visibility" Value="Collapsed" />
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </Grid.Resources>
                        
                        <StackPanel Orientation="Vertical">
                            <Grid x:Name="gridContactConfig" Focusable="True" Margin="0,10,0,0"
                                  HorizontalAlignment="Center">
                                <ListBox x:Name="listContacts" 
                                    AllowDrop="True" 
                                    ItemTemplate="{StaticResource contactEntryTemplate}" 
                                    HorizontalAlignment="Center" 
                                    VerticalAlignment="Top"
                                    ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                                    ScrollViewer.VerticalScrollBarVisibility="Disabled" 
                                    BorderBrush="{x:Null}" 
                                    Background="{x:Null}"/>
                            </Grid>
                            <Grid x:Name="gridMessage" Visibility="Collapsed" Margin="0,10,0,0">
                                <Border BorderBrush="#70FB350B" Background="#70FB350B" CornerRadius="2" Width="200" 
                                        BorderThickness="1" Padding="0" VerticalAlignment="Center" HorizontalAlignment="Center">
                    		        <TextBlock x:Name="tbMessage" FontFamily="Calibri" FontSize="14" 
                                       Foreground="#FFFFFFFF" HorizontalAlignment="Center" Margin="0,0,0,0"
                                       VerticalAlignment="Center" TextWrapping="Wrap" />
                                </Border>
                            </Grid>
                        </StackPanel>
                    </Grid>
                    
                    <Button x:Name="btnApply" Click="btnApply_Click" VerticalAlignment="Bottom" Content="Apply" Style="{DynamicResource BtnGeneric}" Width="60" Height="20" Margin="0,0,0,10"/>
                    <Button x:Name="btnCancel" Click="btnCancel_Click" VerticalAlignment="Bottom" HorizontalAlignment="Right" Content="Close" Style="{DynamicResource BtnGeneric}" Width="60" Height="20" Margin="0,0,50,10"/>
                    <Button Template="{DynamicResource ImageButton}" Height="29" Width="29" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,10,5" x:Name="btnHelp">
                        <Image Width="29" Height="29" Source="Resources\Images\helpBtn.png" Stretch="Uniform" StretchDirection="DownOnly"/>
                    </Button>
                    <Grid x:Name="tooltip"  Opacity="0" Width="250" Height="350" VerticalAlignment="Bottom" Visibility="Hidden"  HorizontalAlignment="Right" Margin="0,0,26,13">
                    	<Image Source="{StaticResource toolTip}" />                    		
                    	<TextBlock Foreground="#FFFFFF" FontSize="8.7pt" Margin="17,60,40,20" TextWrapping="Wrap" 
                                   VerticalAlignment="Stretch" HorizontalAlignment="Stretch" TextAlignment="Left">
                            <Run FontSize="9.3pt" Text="Desktop Contact Configuration"/>
                            <LineBreak />
                            <LineBreak />
                            <Run Foreground="#9FFFFFFF" Text="Display Contacts on your desktop and be alerted to changes in their status."/>
                            <LineBreak />
                            <LineBreak />
                            <Run Foreground="#9FFFFFFF" Text="Display a Contact on the desktop by dragging it into an empty slot from your contact list Office Communicator 2007."/>
                            <LineBreak />
                            <LineBreak />
                            <Run Foreground="#9FFFFFFF" Text="Modify the Contact's display name by editing the text in the second textbox."/>
                        </TextBlock>
                    </Grid>
    			</Grid>
            </Border>
        </Border>
    </Grid>
</Page>
